home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.std.c
- Path: in1.uu.net!jyacc!usenet
- From: jtrigg@marks.jyacc.com (Jim Trigg)
- Subject: Re: Restrictions on qsort compare function?
- In-Reply-To: pcurran@inforamp.net's message of Mon, 08 Apr 1996 17:14:13 GMT
- X-Nntp-Posting-Host: marks
- Message-ID: <9livf9cusp.fsf@marks.jyacc.com>
- Sender: jtrigg@marks.jyacc.com
- Organization: JYACC, Inc.
- X-Newsreader: Gnus v5.1
- References: <4iokop$h4p@lyra.csx.cam.ac.uk> <4iqjar$2m9@usenet.pa.dec.com>
- <4jgltp$f9l@lyra.csx.cam.ac.uk> <828644274snz@genesis.demon.co.uk>
- <4k28t4$2g0@sam.inforamp.net> <828726582snz@genesis.demon.co.uk>
- <4k69bf$ehg@sam.inforamp.net> <828971813snz@genesis.demon.co.uk>
- <4kbl1l$74r@sam.inforamp.net>
- Date: Tue, 9 Apr 1996 14:54:14 GMT
-
- In article <4kbl1l$74r@sam.inforamp.net> pcurran@inforamp.net (Peter
- Curran) writes:
-
- > On Mon, 08 Apr 96 13:56:53 GMT in article
- > <828971813snz@genesis.demon.co.uk> Lawrence Kirby
- > <fred@genesis.demon.co.uk> (Lawrence Kirby) wrote:
-
- >>> IMHO, qsort() is required to return an array that is sorted
- >>> according to the criteria implied by the comparison function.
- >>> That is, at the point where qsort returns, the array must match
- >>> the order implied by the comparison function.
-
- > The comparison function I postulated *is* consistent, at any instant
- > in time. (Just to be clear - another correspondent suggested my
- > original posting may not have said quite what I intended. The
- > comparison function I suggested., or intended, calculates as result
- > by comparison of the values pointed at by the parameters, in a way
- > we can all agree is acceptable. However, it then calls time(), and
- > if the result it odd it negates the result before returning it. In
- > a conventional implementation of time(), it reverses the order every
- > second, but defines a consistent order at any given time.)
-
- So what happens if the array is large enough that qsort takes longer
- than a second to complete? The return values from the comparison
- function are no longer consistent. Is the compiler vendor then
- obligated to produce an implementation of qsort that will complete a
- sort in a constant amount of time? That is what breaks your
- comparison function.
-
- Just a Thought,
- Jim Trigg
-